home *** CD-ROM | disk | FTP | other *** search
/ The Original Shareware 1.1 / The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso / 6 / coreaids.zip / EXECUTE.ASM < prev    next >
Assembly Source File  |  1987-06-25  |  2KB  |  86 lines

  1. ;    DESC:    Loads and Executes another program                   V1.00
  2. ;    IN:    *{SEG_VAL} segment and
  3. ;        *{OFFSET} offset of filename to run including extension
  4. ;        *{PAR_HI} high word and
  5. ;        *{PAR_LO} low word of pointer to command line
  6. ;         to be passed to new program. Command line should be in the
  7. ;         form N,' ',PARAM,0DH where N is the length of PARAM+1, and is
  8. ;         followed by a space. PARAM is the command line and 0DH is
  9. ;         a carriage return ending the line.
  10. ;        *{MEMBLK} segment value of last memory control block 
  11. ;         segment is typically the value of DS at entry to the main
  12. ;         program.
  13. ;        *{SIZE} size of main calling program in segment form
  14. ;    SAMPLE:    Callm    EXECUTE,<SEG_VAL,OFFSET,PAR_HI,PAR_LO,MEMBLK,SIZE>,
  15. ;    ###################################################################
  16.  
  17. EXECUTED Segment Para Public 'DATA'
  18. FCB1        DB    0,11 DUP(20),4 DUP(0)    ;default FCB.
  19.  
  20. PBLOCK        DW    0            ;parameter block.
  21. PARAML        DW    0            ;parameter offset
  22. PARAMH        DW    0            ;and segment.
  23.         DD    FCB1
  24.         DD    FCB1
  25. EXECUTED Ends
  26.  
  27.     Extrn    PUSHALL:Near            ;save and restore registers.
  28.     Extrn    POPALL:Near
  29.     Extrn    ERRORMSG:Near            ;display error messages.
  30.     Extrn    ALOC_CHG:Near            ;change memory allocation.
  31.  
  32. EXECUTEC    Segment Para Public 'CODE'
  33.     Assume CS:EXECUTEC,DS:EXECUTED
  34.     Public    EXECUTE
  35.  
  36. SSEG        DW    0            ;save stack segment.
  37. SPTR        DW    0            ;save stack pointer.
  38.  
  39.     Include    CALLM.MAC            ;macro call program.
  40.  
  41.                         ;notice.
  42.     DB    'EXECUTE  - V1.00, Copyright 1987, CoreTechs   ',0DH,0AH
  43.  
  44. EXECUTE    Proc    Near
  45.  
  46.     Call    PUSHALL                ;save registers.
  47.  
  48.     Mov    AX,EXECUTED            ;load workarea.
  49.     Mov    DS,AX
  50.  
  51.     Pop    BX                ;size of current program.
  52.     Pop    ES                ;recover memory control block.
  53.     Pop    PARAML                ;low word of parametr pointer.
  54.     Pop    PARAMH                ;high word of param. pointer.
  55.  
  56.     Callm    ALOC_CHG,<ES,BX>,        ;change memory allocation.
  57.  
  58.     Mov    AX,DS
  59.     Mov    ES,AX                ;set ES:DX to segment and
  60.     Mov    BX,OFFSET PBLOCK        ;offset of parameter block.
  61.  
  62.     Pop    DX                ;offset of command filename.
  63.     Pop    DS                ;segment of command filename.
  64.  
  65.     Mov    AX,4B00H            ;EXEC function.
  66.  
  67.     Mov    CS:[SSEG],SS            ;save stack.
  68.     Mov    CS:[SPTR],SP
  69.  
  70.     Int    21H                ;call DOS.
  71.  
  72.     Mov    SP,CS:[SPTR]            ;restore stack.
  73.     Mov    SS,CS:[SSEG]
  74.  
  75.     Jc    ERROR                ;if error notify.
  76.  
  77.     Call    POPALL
  78.     Ret
  79.  
  80. ERROR:    Push    AX                ;error return.
  81.     Call    ERRORMSG
  82.  
  83. EXECUTE    Endp
  84. EXECUTEC    Ends
  85.     End
  86.